package com.arpa.wms.domain.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Digits;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 收货明细
 * </p>
 *
 * @author LEO
 * @since 2020-08-04
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("wms_receive_item")
@ApiModel(value="ReceiveItem对象", description="收货明细")
public class ReceiveItem extends BasicEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "数据标识")
    @TableField("code")
    private String code;

    @ApiModelProperty(value = "收货单号")
    @TableField("receive_code")
    private String receiveCode;

    @ApiModelProperty(value = "组织机构")
    @TableField("group_code")
    private String groupCode;

    @ApiModelProperty(value = "来源单item标识")
    @TableField("source_item_code")
    @Length(max = 100, message = "来源单item标识长度不能大于100", groups = {Receive.Save.class, Receive.Update.class})
    private String sourceItemCode;

    @ApiModelProperty(value = "商品标识")
    @TableField("goods_code")
    private String goodsCode;

    @ApiModelProperty(value = "商品编码")
    @TableField("good_code")
    private String goodCode;

    @ApiModelProperty(value = "商品名称")
    @TableField("goods_name")
    private String goodsName;

    @ApiModelProperty(value = "商品条码")
    @TableField("goods_bar_code")
    private String goodsBarCode;


    @ApiModelProperty(value = "商品规格")
    @TableField("spec")
    private String spec;

    @ApiModelProperty(value = "保质期（天）")
    @TableField("expiration_quantity")
    private BigDecimal expirationQuantity;

    @ApiModelProperty(value = "单位")
    @TableField("goods_unit")
    private String goodsUnit;

    @ApiModelProperty(value = "单位名称")
    @TableField("goods_unit_name")
    private String goodsUnitName;

    @ApiModelProperty(value = "基本单位")
    @TableField("basic_unit")
    private String basicUnit;

    @ApiModelProperty(value = "基本单位名称")
    @TableField("basic_unit_name")
    private String basicUnitName;

    @ApiModelProperty(value = "当前商品单位转基本单位件装量")
    @TableField("unit_convert_quantity")
    private BigDecimal unitConvertQuantity;

    @ApiModelProperty(value = "计划数量")
    @TableField("plan_quantity")
    @Digits(integer = 14,fraction = 6, message = "明细数量超过了允许范围（只允许14位整数和6位小数范围内）", groups = {Receive.Save.class, Receive.Update.class})
    private BigDecimal planQuantity;

    @ApiModelProperty(value = "入库数量")
    private BigDecimal inboundQuantity;

    @ApiModelProperty(value = "收货数量")
    @TableField("received_quantity")
    private BigDecimal receivedQuantity;

    @ApiModelProperty(value = "退货数量（收货单位）")
    @TableField("refund_quantity")
    private BigDecimal refundQuantity;

    @ApiModelProperty(value = "退货数量（基本单位）")
    @TableField("refund_basic_quantity")
    private BigDecimal refundBasicQuantity;

    @ApiModelProperty(value = "上架数量")
    @TableField("putaway_quantity")
    private BigDecimal putawayQuantity;

    @ApiModelProperty(value = "生产日期")
    @TableField("gmt_manufacture")
    private LocalDateTime gmtManufacture;

    @ApiModelProperty(value = "过期日期")
    @TableField("gmt_expire")
    private LocalDateTime gmtExpire;


    @ApiModelProperty(value = "状态  0 ：待收货；1：部分收货；2：收货完成")
    @TableField("status")
    private String status;

    @ApiModelProperty(value = "备注")
    @TableField("remarks")
    @Length(max = 100, message = "明细备注长度不能大于100", groups = {Receive.Save.class, Receive.Update.class})
    private String remarks;

    @ApiModelProperty(value = "所属组合商品Code")
    @TableField("compose_good_code")
    private String composeGoodCode;

    @ApiModelProperty(value = "退货数量")
    @TableField("return_quantity")
    private BigDecimal returnQuantity;

    @ApiModelProperty(value = "退货关联的发货单明细code")
    @TableField("delivery_item_code")
    private String deliveryItemCode;

    @ApiModelProperty(value = "取消数量")
    @TableField(exist = false)
    private BigDecimal cancelQuantity=BigDecimal.ZERO;

    @ApiModelProperty(value = "收货登记明细")
    @TableField(exist = false)
    private List<ReceiveRegister> receiveRegisterList = new ArrayList<>();

}
